﻿<!DOCTYPE html>
<html>
<head>
    <title>修改密码</title>
    $css()
</head>
<body>
    <div class="_tabarea">
        <!--
            <div class="tab_mini">
                <a href="?module=system&amp;action=appconfig">应用程序设置</a>
                <a href="?module=system&amp;action=modifyuserbasicprofile"  onclick="return false" class="current">修改个人资料</a>
                <a href="?module=system&amp;action=settingsconfig">词典设置</a>
            </div>
            -->
        <div class="area" id="area">

            <form action="" method="post" id="form_userProfile">
                <div class="form" style="width:400px;padding:20px">
                    <div class="fl">
                        <div class="label"><span class="red">*</span>显示名称：</div>
                        <div class="in">
                            <input type="text" class="ui-validate" required="true" length="[,10]" field="Name" value="${name}" />
                            <div class="tip">10字以下</div>
                        </div>
                    </div>

                    <div class="fl">
                        <div class="label">头像：</div>
                        <div class="in">
                            <input type="text" class="ui-validate" field="Avatar" />
                            <div class="tip">(*开发中)</div>
                        </div>
                    </div> 


                    <div class="title"><span class="icon icon1"></span>修改密码</div>

                    <div class="fl">
                        <div class="label">原密码：</div>
                        <div class="in">
                            <input class="ui-validate" type="password" field="opwd" length="[,20]" />
                            <div class="tip">输入原密码</div>
                        </div>
                    </div> 

                    <div class="fl">
                        <div class="label">新密码：</div>
                        <div class="in">
                            <input class="ui-validate" type="password" field="pwd" length="[,20]" />
                        </div>
                    </div> 


                    <div class="fl">
                        <div class="label">确认密码：</div>
                        <div class="in">
                            <input class="ui-validate" type="password" field="repwd" length="[,20]" />
                            <div class="tip">重复输入新密码</div>
                        </div>
                    </div> 

                    <div class="fl">
                        <div class="label"></div>
                        <div class="in">
                            <a class="btn" id="btn" href="javascript:;">确定</a>
                        </div>
                    </div> 

                </div>
            </form>

        </div>
    </div>
    $js()
    <script type="text/javascript">
        cms.$("btn").onclick = function () {
            var form = cms.$('form_userProfile');
            var json = cms.json.toObject(form);
            var inputs = form.getElementsByTagName('INPUT');
            if (json.name == '') {
                cms.validator.setTip(inputs[0], false, null, '请输入名称!');
                return false;
            }
            if (json.pwd != '') {
                if (json.opwd == '') {
                    cms.validator.setTip(inputs[1], false, null, '请输入密码!'); return false;
                }
                else if (json.pwd != json.repwd) {
                    cms.validator.setTip(inputs[3], false, null, '新密码两次输入不一致!'); return false;
                }
            }

            if (cms.validator.validate(form.id)) {
                cms.xhr.jsonPost('?module=user&action=modifyUserBasicProfile', json, function (json) {
                    if (json.result) {
                        window.parent.M.alert('修改成功');
                        //cms.tab.close();
                    } else {
                        cms.validator.setTip(inputs[1], false, null, json.message);
                    }
                });
            }
        };


    </script>

</body>
</html>
